package com.iplus.ydkf.ehome.common.utils;

/**
 * Created by lhtde on 2016/5/27.
 */
public class Unicode {
    public static String ChineseToUnicode(String s) {
        String as[] = new String[s.length()];
        String s1 = "";
        for (int i = 0; i < s.length(); i++) {
            as[i] = Integer.toHexString(s.charAt(i) & 0xffff);
            s1 = s1 + "\\u" + as[i];
        }
        return s1;
    }

    public static String UnicodeToChinese(String string) {
        String str = string.replace("\\u", ",");
        String[] s2 = str.split(",");
        String s1 = "";
        for (int i = 1; i < s2.length; i++) {
            s1 = s1 + (char) Integer.parseInt(s2[i], 16);
        }
        return s1;
    }
}
